<?php
    use User\Model\NiudanModel;
?>
<div class="row">
    <div class="col-lg-12">
        <section class="panel">
            <header class="panel-heading">
                按钮设置
            </header>
            <div class="panel-body">
                <form class="form-horizontal" method="post" action="/User/Niudan/button_setting" enctype="multipart/form-data">
                    <input type="hidden" name="upload_id" value="{$niudan['upload_id']}">
                    <input type="hidden" name="update" value="true">
                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label">分享按钮</label>
                        <div class="col-lg-6">
                            <img src="{$niudan['button_share']}" style="width:100px;height:100px" data-preview="uploadFile1">
                            <input type="file" name="picurl1" data-action="uploadFile1">
                            <if condition="$niudan.button_share neq null">
                                <input type="hidden" name="picurl1" value="{$niudan['button_share']}" data-set="uploadFile1">
                            </if>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label">再玩一次按钮</label>
                        <div class="col-lg-6">
                            <img src="{$niudan['button_again']}" style="width:100px;height:100px" data-preview="uploadFile2">
                            <input type="file" name="picurl2" data-action="uploadFile2">
                            <if condition="$niudan.button_again neq null">
                                <input type="hidden" name="picurl2" value="{$niudan['button_again']}" data-set="uploadFile2">
                            </if>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label">自定义按钮</label>
                        <div class="col-lg-6">
                            <div class="col-sm-10">
                                <input type="radio" name="custom_type" value="<?php echo NiudanModel::CUSTOM_TYPE1?>"
                                    <if condition="$niudan['custom_type'] eq NiudanModel::CUSTOM_TYPE1">checked</if>
                                    onclick="custom(0)">关闭&nbsp;&nbsp;
                                <input type="radio" name="custom_type" value="<?php echo NiudanModel::CUSTOM_TYPE2?>"
                                    <if condition="$niudan['custom_type'] eq NiudanModel::CUSTOM_TYPE2">checked</if>
                                    onclick="custom(1)">外链
                                <input type="radio" name="custom_type" value="<?php echo NiudanModel::CUSTOM_TYPE3?>"
                                    <if condition="$niudan['custom_type'] eq NiudanModel::CUSTOM_TYPE3">checked</if>
                                    onclick="custom(2)">一键关注
                            </div>
                        </div>
                    </div>
                    <div id="custom1" <if condition="($niudan.custom_type eq NiudanModel::CUSTOM_TYPE1) or
                        ($niudan.custom_type eq NiudanModel::CUSTOM_TYPE3)">style="display:none"</if>>
                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label">自定义按钮图片</label>
                        <div class="col-lg-6">
                            <img src="{$niudan['custom_image']}" style="width:100px;height:100px" data-preview="uploadFile3">
                            <input type="file" name="picurl3" data-action="uploadFile3">
                            <if condition="$niudan.custom_image neq null">
                                <input type="hidden" name="picurl3" value="{$niudan['custom_image']}" data-set="uploadFile3">
                            </if>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label">外链地址</label>
                        <div class="col-lg-6">
                            <input type="text" class="form-control" name="custom_link" value="{$niudan['custom_link']}">
                        </div>
                    </div>
                    </div>

                    <div id="custom2" <if condition="($niudan.custom_type eq NiudanModel::CUSTOM_TYPE1) or
                        ($niudan.custom_type eq NiudanModel::CUSTOM_TYPE2)">style="display:none"</if>>
                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label">微信公号图片</label>
                        <div class="col-lg-6">
                            <img src="{$niudan['weixin_image']}" style="width:100px;height:100px" data-preview="uploadFile4">
                            <input type="file" name="picurl4" data-action="uploadFile4">
                            <if condition="$niudan.weixin_image neq null">
                                <input type="hidden" name="picurl4" value="{$niudan['weixin_image']}" data-set="uploadFile4">
                            </if>
                        </div>
                    </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-10">
                            <button class="btn btn-primary" type="submit" id="submit">提交</button>
                            <button class="btn btn-default" type="button" onclick="history.back(-1);">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </section>
    </div>
</div>
<script type="text/javascript" src="/Public/js/common.upload.js"></script>
<script type="text/javascript">
    common.upload.img.init();

    function custom(type){
        if(type == 0){
            $("#custom1").hide();
            $("#custom2").hide();
        }else if(type == 1){
            $("#custom1").show();
            $("#custom2").hide();
        }else{
            $("#custom1").hide();
            $("#custom2").show();
        }
    }
</script>